﻿// <copyright file="RecipientConfigurationElement.cs" company="http://www.dymetis.com">
//
// Copyright (c) 2011 Eddie Z. Lin.
//
// This source is subject to the Microsoft Public License.
// See http://www.opensource.org/licenses/ms-pl.
// All other rights reserved.
// 
// </copyright>

namespace Dymetis.TeamAlert.Configuration
{
    using System.ComponentModel;
    using System.Configuration;

    /// <summary>
    /// The RecipientConfigurationElement Configuration Element.
    /// </summary>
    public partial class RecipientConfigurationElement : ConfigurationElement
    {
        /// <summary>
        /// The XML name of the <see cref="Address"/> property.
        /// </summary>
        internal const string AddressPropertyName = "address";

        /// <summary>
        /// The XML name of the <see cref="Type"/> property.
        /// </summary>
        internal const string TypePropertyName = "type";

        /// <summary>
        /// The XML name of the <see cref="Name"/> property.
        /// </summary>
        internal const string NamePropertyName = "name";

        /// <summary>
        /// The XML name of the <see cref="AllowHtml"/> property.
        /// </summary>
        internal const string AllowHtmlPropertyName = "allowHtml";

        /// <summary>
        /// The XML name of the <see cref="AllowHtml"/> property.
        /// </summary>
        internal const string AttachRawEventPropertyName = "attachRawEvent";

        /// <summary>
        /// Gets or sets the Address.
        /// </summary>
        [Description("The Address.")]
        [ConfigurationProperty(RecipientConfigurationElement.AddressPropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
        public string Address
        {
            get
            {
                return (string)base[RecipientConfigurationElement.AddressPropertyName];
            }

            set
            {
                base[RecipientConfigurationElement.AddressPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the Type.
        /// </summary>
        [Description("The Type.")]
        [ConfigurationProperty(RecipientConfigurationElement.TypePropertyName, IsRequired = true, IsKey = false, IsDefaultCollection = false)]
        public string Type
        {
            get
            {
                return (string)base[RecipientConfigurationElement.TypePropertyName];
            }

            set
            {
                base[RecipientConfigurationElement.TypePropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        [Description("The Name.")]
        [ConfigurationProperty(RecipientConfigurationElement.NamePropertyName, IsRequired = true, IsKey = true, IsDefaultCollection = false)]
        public string Name
        {
            get
            {
                return (string)base[RecipientConfigurationElement.NamePropertyName];
            }

            set
            {
                base[RecipientConfigurationElement.NamePropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether HTML is allowed for sending E-Mail.
        /// </summary>
        [Description("The AllowHtml.")]
        [ConfigurationProperty(RecipientConfigurationElement.AllowHtmlPropertyName, IsRequired = false, IsKey = false, IsDefaultCollection = false, DefaultValue = true)]
        public bool AllowHtml
        {
            get
            {
                return (bool)base[RecipientConfigurationElement.AllowHtmlPropertyName];
            }

            set
            {
                base[RecipientConfigurationElement.AllowHtmlPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the raw event XML will be attched.
        /// </summary>
        [Description("The AttachRawEvent.")]
        [ConfigurationProperty(RecipientConfigurationElement.AttachRawEventPropertyName, IsRequired = false, IsKey = false, IsDefaultCollection = false, DefaultValue = false)]
        public bool AttachRawEvent
        {
            get
            {
                return (bool)base[RecipientConfigurationElement.AttachRawEventPropertyName];
            }

            set
            {
                base[RecipientConfigurationElement.AttachRawEventPropertyName] = value;
            }
        }

        /// <summary>
        /// Gets a value indicating whether the element is read-only.
        /// </summary>
        /// <returns>
        /// A value indicating whether the element is read-only.
        /// </returns>
        public override bool IsReadOnly()
        {
            return false;
        }
    }
}
